package com.finapps.stopspend.entidades;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.Calendar;

import com.finapps.stopspend.util.CalendarUtils;


public class Carrec {
	private Long id;
	private String data;
	private String hora;
	private String descripcio;
	private BigDecimal carrec;
	private BigDecimal saldo;
	private BigDecimal estalviMesAcumulat;
	DecimalFormat df = new DecimalFormat( "#########0.00");

	 
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getData() {
		return data;
	}
	public void setData(String data) {
		this.data = data;
	}
	public String getHora() {
		return hora;
	}
	public void setHora(String hora) {
		this.hora = hora;
	}
	public String getDescripcio() {
		return descripcio;
	}
	public void setDescripcio(String descripcio) {
		this.descripcio = descripcio;
	}
	public BigDecimal getCarrec() {
		return carrec;
	}
	public void setCarrec(BigDecimal carrec) {
		this.carrec = carrec;
	}
	public BigDecimal getSaldo() {
		return saldo;
	}
	public String getStringSaldo(){
		return df.format(saldo);
	}
	public void setSaldo(BigDecimal saldo) {
		this.saldo = saldo;
	}
	public BigDecimal getEstalviMesAcumulat() {
		return estalviMesAcumulat;
	}
	public String getStringEstalviMesAcumulat() {	
		return df.format(estalviMesAcumulat);
	}
	public Calendar getDataAsCalendarSenseTemps() {
		return CalendarUtils.data2Calendar(data);
	}
	public void setEstalviMesAcumulat(BigDecimal estalviMesAcumulat) {
		this.estalviMesAcumulat = estalviMesAcumulat;
	}
	public Carrec(Long id, String data, String hora, String descripcio,
			BigDecimal carrec, BigDecimal saldo, BigDecimal estalviMesAcumulat) {
		super();
		this.id = id;
		this.data = data;
		this.hora = hora;
		this.descripcio = descripcio;
		this.carrec = carrec;
		this.saldo = saldo;
		this.estalviMesAcumulat = estalviMesAcumulat;
	}
	
	private String acotadoDecimales(BigDecimal bignumber){
		String nouNumber = bignumber.toString();
		int n = nouNumber.indexOf(".");
		if(n==-1) return nouNumber;
		nouNumber = nouNumber.substring(0, n+3);
		return nouNumber;
	}

	
}
